package com.vertxsample.samples.testhttpclient

import io.vertx.core.Vertx
import io.vertx.ext.web.client.WebClient



class App {
    companion object {
        @JvmStatic
        fun main(args: Array<String>) {
            val vertx = Vertx.vertx()
            val client = WebClient.create(vertx)

            // 发送GET请求
            client
                .get(8888, "localhost", "/json")
                .send { ar ->
                    if (ar.succeeded()) {
                        // 获取响应
                        val response = ar.result()

                        println("Received response with status code" + response.statusCode())
                        println("Received response " + response.bodyAsString())
                    } else {
                        println("Something went wrong " + ar.cause().message)
                    }
                    vertx.close()
                }
        }
    }
}